package com.clwl.supervise.superviseapp.controller.notice;

import com.clwl.supervise.superviseapp.entity.result.ResultEntity;
import com.clwl.supervise.superviseapp.entity.supervise.JgNotice;
import com.clwl.supervise.superviseapp.service.notice.JgNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("notice")
public class JgNoticeController {
    @Autowired
    JgNoticeService jgNoticeService;

    /**
     *
     * 获取通知信息列表
     * @param pageNum
     * @param pageSize
     * @param noticeType
     * @return
     */
    @GetMapping("getNotice")
    private ResultEntity<Map<String,Object>> getNotice(@RequestParam(required = true) Integer pageNum, @RequestParam(required = true) Integer pageSize,Long noticeType){
        Map<String, Object> resultMap=  jgNoticeService.getNoticeByType(pageNum,pageSize,noticeType);
        if(null==resultMap||resultMap.isEmpty()){
            return ResultEntity.error("获取通知信息失败");
        }
        return ResultEntity.success(resultMap);
    }

    /**
     * 获取通知信息详情
     * @param id
     * @return
     */
    @GetMapping("getNoticeDetail")
    private ResultEntity<JgNotice> getNoticeDetail(Long id){
        JgNotice jgNotice=  jgNoticeService.getJgNoticeDetail(id);
        if(null==jgNotice){
            return ResultEntity.error("获取通知详细信息失败");
        }
        return ResultEntity.success(jgNotice);
    }

}
